<template>
    <li>
        <label>
            <input type="checkbox" :checked="side.choose" @change="handleCheck(side.id)">
            <span>{{ side.title }}</span>
        </label>
        <button class="btn btn-danger" @click="handleDelete(side.id)">删除</button>
    </li>
</template>
<script>
    import bus from '@/utils/bus';

    export default{
        name:'AddSideItem',
        props: ['side'],
    
        setup() {
            
            function handleCheck(id) {
                bus.emit('checkside', id);
            }

            function handleDelete(id) {
                if(confirm('确认要删除这条边吗?')) {
                    bus.emit('deleteside', id);
                }
            }

            return {
                handleCheck,
                handleDelete
            }
        }
    }
</script>
<style scoped>
li{
    box-sizing: border-box;
    list-style: none;
    height: 2.25rem;
    line-height: 2.25rem;
    padding: 0 .3125rem;
    border-bottom: 1px solid #ddd;
}
li label{
    float: left;
    cursor: pointer;
}
li label input{
    vertical-align: middle;
    margin-right: .375rem;
    position: relative;
    top: -0.0625rem;
    cursor: pointer;
}
li button{
    float: right;
    display: none;
    margin-top: .1875rem;
}
li ::before{
    content: initial;
}
li :last-child{
    border-bottom: none;
}
li:hover{
    color: red;
    background-color: #ddd;
}
li:hover button{
    display: block;
}
</style>